<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>轮询</title>
</head>

<body>
  <div id="root"></div>

  <script>
    // fetch('/time').then(res => res.json()).then(data => console.log(data))
    setInterval(async () => {
      let { time, ip } = await (await fetch('/time')).json()
      document.querySelector('#root').innerHTML = `
        <h3>当前时间：${time} -- 您的ip地址：${ip}</h3>
      `
    }, 5000);


  </script>

</body>

</html>